package com.dina.saas.peccancy.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

public class MessageUtil {
	private static final String CONFIG_FILE = "cfg.properties";
	private static Properties p;
	static {
		InputStream inputStream = MessageUtil.class.getClassLoader()
				.getResourceAsStream(CONFIG_FILE);
		p = new Properties();
		try {
			p.load(inputStream);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}

	public static String getMessage(String key) {
		String str = null;
		try {
			String value = p.getProperty(key);
			if (null == value) {
				return null;
			}
			str = new String(p.getProperty(key).getBytes("ISO8859-1"), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return str;
	}

	public static String get(String key) {
		return MessageUtil.getMessage(key);
	}

}
